<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateVShippingTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('v_shipping', function (Blueprint $table) {
            $table->increments('id');
            $table->bigInteger('order_id')->default(0)->comment('订单ID');
            $table->bigInteger('msg_fee_id')->default(0)->comment('信息费ID');
            $table->string('shipping_no',32)->default('')->comment('运货编号');
            $table->uuid('driver_uuid')->comment('司机唯一标识');
            $table->integer('load_num')->default(0)->comment('实际装货数量，单位同order表price_unit');
            $table->string('load_pic', 3072)->default('')->comment('装货过磅凭证，多张图片时用英文逗号分隔');
            $table->integer('unload_num')->default(0)->comment('实际卸货数量');
            $table->string('unload_pic', 3072)->default('')->comment('卸货过磅凭证,多张图片时用英文逗号分隔');
            $table->integer('is_valid')->default(1)->comment('运货单是否有效，1有效，-1无效');
            $table->dateTime('shipment_end_time')->comment('发货完成时间（过磅）');
            $table->string('shipment_remark', 512)->default('')->comment('发货备注');
            $table->dateTime('deliver_end_time')->comment('交付完成时间');
            $table->string('deliver_remark', 512)->default('')->comment('交付备注');
            $table->tinyInteger('pay_status')->default(0)->comment('支付状态，0待支付，10货主已支付，20司机确认支付');
            $table->tinyInteger('status')->default(10)->comment('运货状态，10待装货 20待送货 30待付款 40已完成');
            $table->tinyInteger('global_status')->default(0)->comment('货运全局状态（细分），10到达现场 15司机确认装货 20司机完成装货磅单上传 25发货人确认装货 30司机确认到达 35司机完成卸货磅单上传 40收货人送货确认（卸货完成） 50货主付款 55司机结算确认 60结束运单');
            $table->timestamps();
            $table->index('order_id', 'idx_order_id');
            $table->index('shipping_no', 'idx_shipping_no');
            $table->index('driver_uuid', 'idx_driver_uuid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('v_shipping');
    }
}
